import {businessThesaurusList,configurationNew,deployDelete,lexiconImport,lexiconTemplate,lexiconExport } from '@/services/basiccapacity';

export default {
  namespace:'businessDictionary',

  state: {
  
  },
  effects: {
    *fetch({ payload, callback }, { call, put }) {
      const response = yield call(businessThesaurusList, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *fetchb({ payload, callback }, { call, put }) {
      const response = yield call(configurationNew, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *fetchc({ payload, callback }, { call, put }) {
      const response = yield call(deployDelete, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *fetchd({ payload, callback }, { call, put }) { // 导入
      const response = yield call(lexiconImport, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *fetche({ payload, callback }, { call, put }) {// 导入模版
      const response = yield call(lexiconTemplate, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *fetchf({ payload, callback }, { call, put }) { // 导出
      const response = yield call(lexiconExport, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    
  },

  reducers: {
    save(state, { payload }) {
      return {
        ...state,
        ...payload,
      };
    },
    clear() {
      return {
       
      };
    },
  },
};
